/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dnbW.uiW.queryW.modelW;

import dnbW.dbW.PathExpression;
import dnbW.dbW.sucxentdbW.Identifier;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.HashSet;
import java.util.Set;
import javax.swing.tree.DefaultMutableTreeNode;

/**
 *
 * @author zhouyong, modified by John Truong Ba Quan
 */
public class ConditionNodeLeafObject {

    // <editor-fold desc="ID">
    private String id;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        //edited by yiwei 2009
        String oldId = this.id;
        this.id = id;
        propertyChangeSupport.firePropertyChange("id", oldId, id);
    }

    public void resetId() {
        String oldId = this.id;
        this.id = null;
        propertyChangeSupport.firePropertyChange("id", oldId, null);
    }
    // </editor-fold>

    // <editor-fold desc="Identity Path Table">
    private String identityPathTable;

    public boolean isIdentityPathAvailable() {
        return (this.getIdentityPathTable() != null);
    }

    public String getIdentityPathTable() {
        return identityPathTable;
    }

    // this method should be called once and only once
    // if not called, this object is invalid
    // if called more than once, this object's behaviour is undefined
    public void setIdentityPathTable(String identityPathTable) {
        this.identityPathTable = identityPathTable;
        propertyChangeSupport.firePropertyChange(
                "identityPathTable",
                null,
                identityPathTable);
    }
    // </editor-fold>

    // <editor-fold desc="Combined Identity Path Table">
    private String combinedIdentityPathTable;

    public boolean isCombinedIdentityPathAvailable() {
        return this.getCombinedIdentityPathTable() != null;
    }

    public String getCombinedIdentityPathTable() {
        return combinedIdentityPathTable;
    }

    public void setCombinedIdentityPathTable(String identityPathTable) {
        this.combinedIdentityPathTable = identityPathTable;
    }
    // </editor-fold>

    // <editor-fold desc="Identity Path Count">
    private int identityPathCount;

    public int getIdentityPathCount() {
        return identityPathCount;
    }

    public void setIdentityPathCount(int identityPathCount) {
        int oldCount = this.getIdentityPathCount();
        this.identityPathCount = identityPathCount;
        propertyChangeSupport.firePropertyChange(
                "identityPathCount",
                oldCount,
                this.getIdentityPathCount());
    }
    // </editor-fold>

    // <editor-fold desc="Identity Path Mapper">
    private Set<Identifier> identityPathMapper = new HashSet<Identifier>();

    public Set<Identifier> getIdentityPathMapper() {
        return identityPathMapper;
    }

    public void resetIdentityPathMapper() {
        identityPathMapper = new HashSet<Identifier>();
    }
    // </editor-fold>

    // <editor-fold desc="Property Change Support">
    protected final PropertyChangeSupport propertyChangeSupport =
            new PropertyChangeSupport(this);

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertyChangeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertyChangeSupport.removePropertyChangeListener(listener);
    }
    // </editor-fold>

    // <editor-fold desc="Allow Merging">
    /**
     * Indicates whether the system could process this node together with nearby nodes
     */
    private boolean allowMerging = true;

    public boolean isAllowMerging() {
        return allowMerging;
    }

    public void setAllowMerging(boolean allowMerging) {
        this.allowMerging = allowMerging;
    }
    // </editor-fold>

    public ConditionNodeLeafObject() {
        //super(node);
    }

//    abstract public String getXPath(PathExpression outputPath);
//
//    abstract public String getXPath(PathExpression outputPath, ConditionCluster CurrentConditionCluster);
//
//    abstract public String getXQuery(PathExpression outputPath);
}
